using System.Collections.Generic;
using UnityEngine;

namespace MLTimeline
{
    [System.Serializable]
    public class Timeline
    {
        public float frameRate = 30.0f;
        [SerializeReference]
        public List<Track> tracks = new();

        public int TotalFrames { get; private set; }

#if UNITY_EDITOR
        /// <summary>
        /// 缩放系数
        /// </summary>
        public float zoomLevel = 1f;
        /// <summary>
        /// 水平滚动值
        /// </summary>
        public float horizontalScroll = 0f;
#endif

        public void Initialize()
        {
            //合法数据校验
            for (var i = 0; i < tracks.Count; i++)
            {
                if (tracks[i] == null) continue;
                tracks[i].Initialize(this);
                TotalFrames = Mathf.Max(TotalFrames, tracks[i].MaxFrameCount);
            }
        }
    }
}